<template>
  <div class="template-area">
    <div class="screen-area item">
      <div class="left screen-info">
        <el-form ref="form" :model="form" :inline="true">
          <el-form-item label="模板名称" prop="title">
            <el-input v-model="form.title" size="small" clearable />
          </el-form-item>
          <el-form-item label="终端类型" prop="devType">
            <el-select
              v-model="form.devType"
              placeholder="请选择"
              size="small"
              clearable
            >
              <el-option
                v-for="item in getDeviceType"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="业务类型" prop="bizType">
            <el-select
              v-model="form.bizType"
              placeholder="请选择"
              size="small"
              clearable
            >
              <el-option
                v-for="item in getBizType"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button
              icon="el-icon-search"
              type="primary"
              @click="handleSubmit('form')"
              size="small"
            >
              搜索
            </el-button>
            <el-button @click="handleResets('form')" size="small"
              >重置</el-button
            >
          </el-form-item>
        </el-form>
      </div>
      <div class="right screen-info">
        <el-button type="primary" size="small" @click="handleAdd"
          >新增模板库</el-button
        >
      </div>
    </div>
    <div class="list-area item">
      <el-table border stripe class="table-area" :data="templateListInfos.list">
        <el-table-column prop="title" label="模板名称">
          <template v-slot="scope">
            <div class="name" @click="handleDetail(scope.row)">
              <el-popover
                placement="right"
                title="模板效果图"
                :popper-class="setPopperClass(scope.row)"
                width="200"
                trigger="hover"
              >
                <div class="cover-image-area">
                  <img :src="`${scope.row.coverImage}?t=${getOnlyId()}`" />
                </div>
                <div class="name-inside" slot="reference">
                  {{ scope.row.title }}
                </div>
              </el-popover>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="devType" label="终端类型">
          <template v-slot="scope">
            <div>{{ changeDevTypeName(scope.row.devType) }}</div>
          </template>
        </el-table-column>

        <el-table-column prop="bizType" label="业务类型">
          <template v-slot="scope">
            <div>{{ changeBizTypeName(scope.row.bizType) }}</div>
          </template>
        </el-table-column>

        <el-table-column prop="resolution" label="分辨" />
        <el-table-column prop="createTime" label="创建时间" />

        <el-table-column label="操作">
          <template v-slot="scope">
            <el-row class="operator-box">
              <el-col
                :push="8"
                :span="4"
                class="edit item"
                @click.native="handleEdit(scope.row)"
                title="编辑"
                >编辑
              </el-col>
              <el-col
                :push="8"
                :span="4"
                class="delete item"
                @click.native="handleDelete(scope.row)"
                title="删除"
              >
                删除
              </el-col>
            </el-row>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination-box">
        <Pagination
          :pageInfo="templateListInfos"
          @handleChangePage="handleChangePage"
        />
      </div>
    </div>

    <TemplateCreate
      :visible="templateCreate.visible"
      :info="templateCreate.formInfo"
      :type="templateCreate.type"
      @handleCancel="handleCancel"
      @handleSure="handleSure"
    />

    <TemplateDelete
      :visible="templateDelete.visible"
      :info="templateDelete.info"
      @handleCancel="handleCancel"
      @handleSure="handleSure"
    />

    <!--            <ReportSelectBusiness-->
    <!--                :info="reportInfo.info"-->
    <!--                :visible="reportInfo.visible"-->
    <!--                @handleCancel="handleCancel"-->
    <!--                @handleBusiness="handleBusiness"-->
    <!--            />-->

    <!--            <CallPatient-->
    <!--                :info="callPatientInfo.info"-->
    <!--                @handleCancel="handleCancel"-->
    <!--                :visible="callPatientInfo.visible"-->
    <!--                :checkList="callPatientInfo.checkList"-->
    <!--            />-->

    <!--    <CallPatientSmall-->
    <!--        :info="callPatientInfo.info"-->
    <!--        @handleCancel="handleCancel"-->
    <!--        :visible="callPatientInfo.visible"-->
    <!--        :checkList="[3]"-->
    <!--    />-->

    <!--             <CallPatientDrawer-->
    <!--                 :info="callPatientInfo.info"-->
    <!--                 @handleCancel="handleCancel"-->
    <!--                 :visible="callPatientInfo.visible"-->
    <!--                 :checkList="[2,3]"-->
    <!--              />-->

    <!--        <CallPatientDrawerBottom-->
    <!--            :checkList="[2,3]"-->
    <!--            :info="callPatientInfo.info"-->
    <!--            :visible="callPatientInfo.visible"-->
    <!--            @handleCancel="handleCancel"-->
    <!--        />-->

    <!--    <CallPatientDrawerRight-->
    <!--        :checkList="[2,3]"-->
    <!--        :info="callPatientInfo.info"-->
    <!--        :visible="callPatientInfo.visible"-->
    <!--        @handleCancel="handleCancel"-->
    <!--    />-->

    <!--    <CallPatientDrawerLeft-->
    <!--        :checkList="[2,3]"-->
    <!--        :info="callPatientInfo.info"-->
    <!--        :visible="callPatientInfo.visible"-->
    <!--        @handleCancel="handleCancel"-->
    <!--    />-->

    <!--           <CallPatientArt-->
    <!--                :info="callPatientInfo.info"-->
    <!--                @handleCancel="handleCancel"-->
    <!--                :visible="callPatientInfo.visible"-->
    <!--                :checkList="[1,2,3]"-->
    <!--            />-->

    <!--        <RoomCallPatient-->
    <!--            :info="callPatientInfo.info"-->
    <!--            @handleCancel="handleCancel"-->
    <!--            :visible="callPatientInfo.visible"-->
    <!--        />-->
    <!--        <RoomCallPatientSmall-->
    <!--            :info="callPatientInfo.info"-->
    <!--            @handleCancel="handleCancel"-->
    <!--            :visible="callPatientInfo.visible"-->
    <!--        />-->

    <!--            <RoomCallPatientTop-->
    <!--                :info="callPatientInfo.info"-->
    <!--                @handleCancel="handleCancel"-->
    <!--                :visible="callPatientInfo.visible"-->
    <!--            />-->

    <!--候诊屏弹层原始数据-->
    <!--                        <RoomCallPatientOriginal-->
    <!--                                :info="callPatientInfo.info"-->
    <!--                                :visible="callPatientInfo.visible"-->
    <!--                                @handleCancel="handleCancel"-->
    <!--                            />-->

    <!--            <RoomCallPatientOriginal2-->
    <!--                :info="callPatientInfo.info"-->
    <!--                :visible="callPatientInfo.visible"-->
    <!--                @handleCancel="handleCancel"-->
    <!--            />-->

    <!--蓝色背景-->
    <!--    <CallPatientOriginal-->
    <!--        :info="callPatientInfo.info"-->
    <!--        :visible="callPatientInfo.visible"-->
    <!--        @handleCancel="handleCancel"-->
    <!--    />-->

    <!--    通用背景-->
    <CallPatientOriginalBiz
      :info="callPatientInfo.info"
      :visible="callPatientInfo.visible"
      @handleCancel="handleCancel"
    />

    <!--        <ReportResult-->
    <!--            data-info="报道结果文案"-->
    <!--            :info="reportInfo.info"-->
    <!--            :visible="reportInfo.visible"-->
    <!--            @handleCancel="handleCancel"-->
    <!--        />-->

    <!--    <ReportDept-->
    <!--        data-info="报道结果文案"-->
    <!--        :info="reportDeptInfo.info"-->
    <!--        :visible="reportDeptInfo.visible"-->
    <!--        @handleCancel="handleCancel"-->
    <!--    />-->

<!--    <ReportDR-->
<!--      data-info="报道结果文案"-->
<!--      :info="reportDRInfo.info"-->
<!--      :visible="reportDRInfo.visible"-->
<!--      @handleCancel="handleCancel"-->
<!--      @handleSure="handleSureDoctor"-->
<!--    />-->

    <CallPatientCurrent
      :info="callPatientCurrentInfo.info"
      @handleCancel="handleCancel"
      :visible="callPatientCurrentInfo.visible"
      :checkList="[2, 3]"
    />

    <CallPatientWindow
      :info="callPatientWindowInfo.info"
      @handleCancel="handleCancel"
      :visible="callPatientWindowInfo.visible"
      :checkList="[2, 3]"
    />

<!--    <CallPatientBlood-->
<!--      :info="callPatientWindowInfo2.info"-->
<!--      :checkList="1"-->
<!--      @handleCancel="handleCancel"-->
<!--      :visible="callPatientWindowInfo2.visible"-->
<!--    />-->

    <!--        <ReportResult2-->
    <!--            data-info="报道结果文案"-->
    <!--            :info="reportInfo.info"-->
    <!--            :visible="reportInfo.visible"-->
    <!--            @handleCancel="handleCancel"-->
    <!--        />-->

    <!--                        <ReportPatient-->
    <!--                            data-info="报道-号别"-->
    <!--                                :info="reportInfo.info"-->
    <!--                                :visible="reportInfo.visible"-->
    <!--                                @handleCancel="handleCancel"-->
    <!--                            />-->

    <!--        <ReportSucessPatient-->
    <!--            data-info="报道-成功患者"-->
    <!--            :info="reportInfo.info"-->
    <!--            :visible="reportInfo.visible"-->
    <!--            @handleCancel="handleCancel"-->
    <!--        />-->

    <!--    <ReportSurePower-->
    <!--        data-info="报道-确认权限"-->
    <!--        :info="reportInfo.info"-->
    <!--        :visible="reportInfo.visible"-->
    <!--        @handleCancel="handleCancel"-->
    <!--        @handleSure="handleCancel"-->
    <!--    />-->

    <!--                <ReportDoctor-->
    <!--                    data-info="报道-选择复诊医生"-->
    <!--                    :info="reportInfo.info"-->
    <!--                    :visible="reportInfo.visible"-->
    <!--                    @handleCancel="handleCancel"-->
    <!--                    @handleSure="handleSureDoctor"-->
    <!--                />-->

    <!--                <RoomInfo-->
    <!--                    :info="roomInfo.info"-->
    <!--                    :visible="roomInfo.visible"-->
    <!--                    @handleCancel="handleCancel"-->
    <!--                />-->

    <!--            <BusinessWinInfo-->
    <!--                :info="roomInfo.info"-->
    <!--                :visible="roomInfo.visible"-->
    <!--                @handleCancel="handleCancel"-->
    <!--            />-->

    <!--            <PopupLoading-->
    <!--                :info="roomInfo.info"-->
    <!--                :visible="roomInfo.visible"-->
    <!--                @handleCancel="handleCancel"-->
    <!--            />-->

    <!--手术患者-->
    <!--    <SurgeryPatient-->
    <!--        :visible="surgeryInfo.visible"-->
    <!--        :info="surgeryInfo.info"-->
    <!--        @handleCancel="handleCancel"-->
    <!--    />-->

    <!--按钮-->
    <div class="button-wrap" v-if="isProd">
      <Button type="primary" size="small" @click="handleShowNingXia"
        >宁夏候诊按钮</Button
      >
      <Button type="primary" size="small" @click="handleShow">候诊按钮</Button>
      <Button type="primary" size="small" @click="handleBusinessInfo"
        >业务信息</Button
      >
      <Button type="primary" size="small" @click="handleOriginalShow"
        >诊室原始数据弹层</Button
      >
      <Button type="primary" size="small" @click="handleShow">诊室按钮</Button>
      <Button type="primary" size="small" @click="handleRoomInfo"
        >诊室号信息</Button
      >
      <Button type="primary" size="small" @click="handleReportBusinessShow"
        >报到机业务</Button
      >

      <Button type="primary" size="small" @click="handleReportDeptShow"
        >报到机选择科室</Button
      >

      <Button type="primary" size="small" @click="handleReportShow">报到机按钮</Button>
      <Button type="primary" size="small" @click="handleLoadingInfo">Loading信息</Button>
      <Button type="primary" size="small" @click="handleSurgeryInfo">手术患者</Button>
      <Button type="primary" size="small" @click="handleReportDRShow">报到机选择医生</Button>
      <Button type="primary" size="small" @click="handleWaitingShow">门诊窗口</Button>
      <Button type="primary" size="small" @click="handleWaitingWindow">药房窗口</Button>
    </div>
  </div>
</template>

<script>
import { Button } from "vant";
import { v4 as uuid } from "uuid";
import Pagination from "@/components/public/pagination";
// 汇总所有弹层组件
import LayerComps from "@/components/public/layer/scenes";
import CodeEditor from "@/components/public/layer/code-editor";
import TemplateCreate from "@/components/public/layer/template/create";
import TemplateDelete from "@/components/public/layer/template/delete";
import { getReportDeptInfo, getReportDeptInfo2 } from "@/store/modules/getters";

export default {
  name: "Template",

  componentName: "Template",

  components: {
    Button,
    CodeEditor,
    TemplateDelete,
    TemplateCreate,
    ...LayerComps,
    Pagination,
  },

  data() {
    return {
      isProd: false,
      roomInfo: {
        visible: false,
        info: Object(),
      },
      reportInfo: {
        visible: false,
        info: Object(),
      },
      reportDeptInfo: {
        visible: false,
        info: Object(),
      },

      reportDRInfo: {
        visible: false,
        info: Object(),
      },

      callPatientCurrentInfo: {
        visible: false,
        info: Object(),
      },

      callPatientWindowInfo: {
        visible: false,
        info: Object(),
      },
      callPatientWindowInfo2: {
        visible: false,
        info: Object(),
      },

      callPatientInfo: {
        visible: false,
        info: Object(),
      },
      // 手术患者信息
      surgeryInfo: {
        visible: false,
        info: Object(),
      },
      templateDelete: {
        visible: false,
        info: Object(),
      },
      templateCreate: {
        visible: false,
        formInfo: {
          title: "",
          devType: 1,
          bizType: 0,
          resolution: "1920*1080",
        },
      },
      form: {
        title: "",
        devType: "",
        bizType: "",
      },
    };
  },

  computed: {
    //生成唯一的字符串
    getOnlyId() {
      return function () {
        return uuid();
      };
    },

    setPopperClass() {
      return function (row) {
        let type = row.devType;
        switch (type) {
          case 1:
            return "wait-popper";
          case 3:
            return "room-popper";
          default:
            return "room-popper";
        }
      };
    },

    // 读取store模板数据
    templateListInfos() {
      return this.$store.getters["template/getTemplateListInfo"];
    },

    // 业务类型
    getDeviceType() {
      return this.$store.getters["template/getDeviceType"];
    },

    //转换终端类型中文名称
    changeDevTypeName() {
      return function (val) {
        let deviceType = this.$store.getters["template/getDeviceType"];
        let info = deviceType.find((item) => {
          return item.value === parseInt(val);
        });
        return info?.label || "未知";
      };
    },

    // 业务类型
    getBizType() {
      return this.$store.getters["template/getBizType"];
    },

    //  转换业务类型的中文名称
    changeBizTypeName() {
      return function (val) {
        let bizType = this.$store.getters["template/getBizType"];
        let info = bizType.find((item) => {
          return item.value === parseInt(val);
        });
        return info?.label || "未知";
      };
    },

    // 报到机-复诊选择医生
    getReportDoctor() {
      return this.$store.getters["getReportDoctorInfo"];
    },

    getReportPatientNumberInfo() {
      return this.$store.getters["getReportPatientNumberInfo"];
    },
  },

  mounted() {
    this.isProd = process.env.NODE_ENV === "development";
    this.templateListInfo();
  },

  methods: {
    // 获取服务端列表信息
    async templateListInfo() {
      let params = this.$store.getters["template/getTemplateListParamsInfo"];
      Reflect.set(params, "pageNum", 1);
      Reflect.set(params, "pageSize", 10);
      await this.$store.dispatch("template/setTemplateList", params);
    },

    // 创建模板
    handleAdd() {
      let temp = Object();
      Reflect.set(temp, "title", "");
      Reflect.set(temp, "devType", 1);
      Reflect.set(temp, "bizType", 0);
      Reflect.set(temp, "resolution", "1920*1080");
      Reflect.set(this.templateCreate, "visible", true);
      Reflect.set(this.templateCreate, "type", "create");
      Reflect.set(this.templateCreate, "formInfo", temp);
    },

    // 编辑模板信息
    handleEdit(row) {
      Reflect.set(this.templateCreate, "visible", true);
      Reflect.set(this.templateCreate, "type", "edit");
      Reflect.set(row, "bizType", parseInt(row.bizType));
      Reflect.set(row, "devType", parseInt(row.devType));
      Reflect.set(this.templateCreate, "formInfo", row);
    },

    // 模板删除
    handleDelete(row) {
      Reflect.set(this.templateDelete, "visible", true);
      Reflect.set(this.templateDelete, "info", row);
    },

    // 关闭弹层
    handleCancel() {
      Reflect.set(this.templateCreate, "visible", false);
      Reflect.set(this.templateDelete, "visible", false);
      Reflect.set(this.callPatientInfo, "visible", false);
      Reflect.set(this.reportInfo, "visible", false);
      Reflect.set(this.roomInfo, "visible", false);
      Reflect.set(this.surgeryInfo, "visible", false);
      Reflect.set(this.reportDeptInfo, "visible", false);
      Reflect.set(this.reportDRInfo, "visible", false);
      Reflect.set(this.callPatientCurrentInfo, "visible", false);
      Reflect.set(this.callPatientWindowInfo, "visible", false);
      Reflect.set(this.callPatientWindowInfo2, "visible", false);
    },

    // 关闭弹层的回调
    async handleSure() {
      let params = this.$store.getters["template/getTemplateListParamsInfo"];
      Reflect.set(params, "pageNum", 1);
      Reflect.set(params, "pageSize", 10);
      await this.$store.dispatch("template/setTemplateList", params);
    },

    // 跳转详情页
    handleDetail(row) {
      this.$router.push({
        path: `/templateDetails/detail/${row.id}`,
      });
    },

    async handleChangePage(pageIndex) {
      let params = this.$store.getters["template/getTemplateListParamsInfo"];
      Reflect.set(params, "pageNum", pageIndex);
      Reflect.set(params, "pageSize", 10);
      await this.$store.dispatch("template/setTemplateList", params);
    },

    // 弹层
    handleShow() {
      let info = Object();
      let currPatient = [
        { orderNo: "预CT1319", patientName: "轩辕青鸿" },
        { orderNo: "A1315", patientName: "司马青峰" },
        { orderNo: "A1316", patientName: "上杉青峰" },
        { orderNo: "A1317", patientName: "李青峰" },
        // {orderNo: 'A1318', patientName: '轩辕青鸿'},
        // {orderNo: '预CT1319', patientName: '沈重'},
        // {orderNo: 'A1320', patientName: '海晏'},
        // {orderNo: 'A1321', patientName: '闻言'},
        // {orderNo: 'A1322', patientName: '华清'},
        // {orderNo: 'A1323', patientName: '上杉青峰'},
      ];
      let waitPatient = [
        { orderNo: "A1314", patientName: "上官图南-上官图南" },
        { orderNo: "A1315", patientName: "杨柳依依" },
        { orderNo: "A1316", patientName: "上官云" },
        { orderNo: "A1317", patientName: "杨柳" },
        { orderNo: "A1318", patientName: "上官云" },
        // {orderNo: 'A1319', patientName: '杨柳'},
        // {orderNo: 'A1320', patientName: '上官云'},
        // {orderNo: 'A1321', patientName: '杨柳'},
        // {orderNo: 'A1322', patientName: '长孙昶'},
        // {orderNo: 'A1323', patientName: '宇文护'},
      ];
      Reflect.set(info, "deptName", "神经内科");
      Reflect.set(info, "treatmentRoomName", "内一科");
      Reflect.set(info, "registerObjName", "号别");
      Reflect.set(info, "workStationName", "工作站名称");
      Reflect.set(info, "currPatient", currPatient);
      // 是否显示就诊弹窗
      Reflect.set(info, "treatingAlert", true);
      // 是否显示候诊弹窗
      Reflect.set(info, 'waitingAlert', true);
      Reflect.set(info, 'waitPatient', waitPatient)
      Reflect.set(info, 'treatingVoiceContentConfig', []);
      Reflect.set(info, 'waitingVoiceContent', '');

      Reflect.set(info, "popupBackground", "rgba(255, 255, 255, 1)");
      Reflect.set(info, "overlayBackground", "rgba(0, 0, 0, 0.1)");

      let layerInfo = {
        current: {
          display: true,
          content: "正在就诊",
          fontSize: 98,
          titleFontWeight: "normal",
          color: "rgba(1, 118, 58, 1)",
          backgroundColor: "rgba(1, 118, 58, 0.2)",
          patientNumberColor: "rgba(0, 89, 179, 1)",
          patientNumberBackground: "rgba(255, 255, 255, 0)",
          patientColor: "rgba(1, 118, 58, 1)",
          patientFontSize: 124,
          popupBackground: "rgba(255, 255, 255, 1)",
          overlayBackground: "rgba(0, 0, 0, .7)",
          patientFontWeight: "normal",
        },
        waiting: {
          display: true,
          content: "等待候诊",
          fontSize: 98,
          titleFontWeight: "normal",
          color: "rgba(138, 106, 54, 1)",
          backgroundColor: "rgba(138, 106, 54, 0.2)",
          patientNumberColor: "rgba(299, 133, 2, 1)",
          patientNumberBackground: "rgba(255, 255, 255, 0)",
          patientColor: "rgba(138, 106, 54, 1)",
          patientFontSize: 124,
          popupBackground: "rgba(255, 255, 255, 1)",
          overlayBackground: "rgba(0, 0, 0, .6)",
          patientFontWeight: "normal",
        },
      };

      Reflect.set(info, "current", layerInfo.current);
      Reflect.set(info, "waiting", layerInfo.waiting);

      Reflect.set(this.callPatientInfo, "checkList", [3, 4]);
      Reflect.set(this.callPatientInfo, "visible", true);
      Reflect.set(this.callPatientInfo, "info", info);
    },

    handleShowNingXia() {
      let info = Object();
      let data = {
        treatingAlert: true,
        waitingAlert: false,
        data: {
          msgId: "9392afbdc17c47d4aa1b125ed1d25f30",
          msgCode: "Qcss_Call_Up_Msg",
          msgContent: {
            workerId: 22544,
            workerName: "边药师",
            terminalName: "边-门诊药房",
            deptName: "门诊药房",
            workStationId: 450,
            treatmentRoomName: "窗口01",
            treatingPatient: {
              bookId: null,
              queuingId: "1906551650134052900",
              deptName: "门诊药房",
              orderNo: "8",
              orderPrefix: null,
              orderNumber: null,
              orderTag: null,
              orderTagColor: null,
              colorPrefix: null,
              ftColor: null,
              bgColor: null,
              patientName: "不*3",
              patientCardNo: null,
              patientIdNo: "003",
              patientShowNo: null,
              treatType: "0",
              treatStatus: null,
              registerObjName: "门药号别",
              registerObjId: null,
              registerObjSimpleName: "门号",
              registerObjGroupName: null,
              registerObjGroupSimpleName: null,
              workerStationId: null,
              treatmentRoomName: null,
              treatmentRoomShortName: null,
              deptCode: null,
              doctorCode: null,
              doctorName: null,
            },
            treatingPatientList: [],
            waitingPatientList: [],
            voicePrompt: "2",
            treatingVoicePlayUrl:
              "http://192.168.31.42:7000/tmp/voice/20250331/calling/1229a2556aff449c91f36eaf838b6460.wav",
            treatingAlert: true,
            treatingVoice: true,
            treatingVoiceCount: 1,
            waitingVoicePlayUrl: null,
            waitingAlert: false,
            waitingVoice: false,
            waitingVoiceCount: 0,
            treatingVoiceContentConfig: [
              { name: "请", type: "text" },
              { name: "排序号", type: "orderNo" },
              { name: "号", type: "hao" },
              { name: "患者姓名", type: "patientName" },
              { name: "到", type: "text" },
              { name: "诊室", type: "treatmentRoomName" },
              { name: "就诊", type: "text" },
            ],
            waitingVoiceContent: "",
          },
        },
        checkList: 3,
        currPatient: [],
        waitPatient: [],
        registerObjNameKey: "registerObjName",
        current: {
          display: true,
          content: "采血",
          backgroundColor: "rgba(125, 241, 254, 1)",
          fontSize: 150,
          color: "rgba(0, 5, 31, 1)",
          patientColor: "rgba(125, 241, 254, 1)",
          patientFontSize: 120,
          patientNumberBackground: "rgba(0, 75, 136, 1)",
        },
        waiting: { content: "候诊" },
        popupBackground: "",
        overlayBackground: "",
      };
      Reflect.set(info, "treatingAlert", true);
      // // 是否显示候诊弹窗
      Reflect.set(info, "waitingAlert", false);
      Reflect.set(info, "data", data);
      Reflect.set(this.callPatientWindowInfo2, "visible", true);
      Reflect.set(this.callPatientWindowInfo2, "info", info);
    },

    handleOriginalShow() {
      let info = Object();
      let data = {
        bizType: "openMsgWin",
        msgContent: {
          workerId: 1990,
          workerName: "马小勇",
          deptName: "耳鼻喉科",
          workStationId: 96,
          treatmentRoomName: "耳鼻喉1诊室",
          terminalNumber: "100001",
          terminalName: "工作站名称",
          treatingPatient: {
            queuingId: 1821909672721027074,
            deptName: "耳鼻喉科",
            orderNo: "预52",
            patientName: "王五133",
            patientIdNo: "281",
            treatType: "0",
            registerObjName: "耳鼻喉科_徐志",
            registerObjSimpleName: "耳_徐",
          },
          treatingPatientList: [
            // {
            //   "queuingId": 1821909672721027074,
            //   "deptName": "耳鼻喉科",
            //   "orderNo": "预52",
            //   "patientName": "法南",
            //   "patientIdNo": "281",
            //   "treatType": "0",
            //   "registerObjName": "耳鼻喉科_徐志",
            //   "registerObjSimpleName": "耳_徐"
            // },
            // {
            //   "queuingId": 1821909672721027074,
            //   "deptName": "耳鼻喉科",
            //   "orderNo": "预52",
            //   "patientName": "道墨",
            //   "patientIdNo": "281",
            //   "treatType": "0",
            //   "registerObjName": "耳鼻喉科_徐志",
            //   "registerObjSimpleName": "耳_徐"
            // },
            {
              queuingId: 1821909672721027071,
              deptName: "耳鼻喉科",
              orderNo: "预52",
              patientName: "厍国栋",
              patientIdNo: "281",
              treatType: "0",
              registerObjName: "耳鼻喉科_徐志",
              registerObjSimpleName: "耳_徐",
            },
            {
              queuingId: 1821909672721027071,
              deptName: "耳鼻喉科",
              orderNo: "预52",
              patientName: "李肆",
              patientIdNo: "281",
              treatType: "0",
              registerObjName: "耳鼻喉科_徐志",
              registerObjSimpleName: "耳_徐",
            },
          ],
          waitingPatientList: [],
          voicePrompt: "2",
          treatingVoicePlayUrl:
            "http://192.168.31.199:7000/tmp/voice/20240810/calling/a61d0c8c21d345299895ddd244825c8a.wav",
          treatingAlert: true,
          treatingVoice: true,
          treatingVoiceCount: 1,
          waitingAlert: true,
          waitingVoice: true,
          waitingVoiceCount: 0,
          treatingVoiceContentConfig: [
            {
              name: "请",
              type: "text",
            },
            {
              name: "患者号",
              type: "orderNo",
            },
            {
              name: "号",
              type: "hao",
            },
            {
              name: "患者姓名",
              type: "patientName",
            },
            {
              name: "到",
              type: "text",
            },

            // {
            //   "name": "科室",
            //   "type": "deptName"
            // },

            // {
            //   "name": "诊室",
            //   "type": "treatmentRoomName"
            // },
            {
              name: "工作站名",
              type: "terminalName",
            },
            {
              name: "就诊",
              type: "text",
            },
          ],
          waitingVoiceContent: "",
        },
      };
      // // 是否显示就诊弹窗
      Reflect.set(info, "treatingAlert", true);
      // // 是否显示候诊弹窗
      Reflect.set(info, "waitingAlert", true);
      Reflect.set(info, "data", data);
      Reflect.set(this.callPatientInfo, "visible", true);
      Reflect.set(this.callPatientInfo, "info", info);
    },

    //报到机弹层
    handleReportShow() {
      let info = Object();
      let patientList = Array();
      // 所有号别信息
      let patientInfos = this.$store.getters["getReportPatientInfo"];
      // 模拟数据
      let patientInfo = patientInfos.mockData;
      if (patientInfo?.signList?.length) {
        patientList = this.$lodash.filter(patientInfo.signList, {
          patientDataStatus: "0",
        });
      } else {
        patientList = Array();
      }
      let topCheckList = ["orderNo", "countNum", "registerNameKey", "roomKey"];
      let bottomCheckList = [
        "deptName",
        "patientCardNoHide",
        "patientName",
        "projectName",
      ];
      Reflect.set(info, "state", 0);
      Reflect.set(info, "title", "报到成功");
      Reflect.set(info, "time", "99");
      Reflect.set(info, "content", "请收起您的号票");
      Reflect.set(info, "doctorList", this.getReportDoctor);
      Reflect.set(info, "patientNumberList", this.getReportPatientNumberInfo);
      // 完成报道患者
      Reflect.set(info, "patientName", "韩世忠");
      Reflect.set(this.reportInfo, "visible", true);
      Reflect.set(this.reportInfo, "info", info);
    },

    handleRoomInfo() {
      let info = Object();
      // Reflect.set(info, 'content', '5诊室');
      Reflect.set(info, "content", "此间已停诊");
      Reflect.set(info, "fontSize", "520");
      Reflect.set(this.roomInfo, "visible", true);
      Reflect.set(this.roomInfo, "info", info);
    },

    handleBusinessInfo() {
      let info = Object();
      Reflect.set(info, "content", "5诊室");
      Reflect.set(info, "content", "此间已停诊");
      Reflect.set(info, "fontSize", "320");
      Reflect.set(info, "color", "white");
      Reflect.set(info, "fontWeight", "normal");
      Reflect.set(this.roomInfo, "visible", true);
      Reflect.set(this.roomInfo, "info", info);
    },

    handleLoadingInfo() {
      let info = Object();
      Reflect.set(info, "type", "spinner");
      Reflect.set(info, "color", "rgb(25, 137, 250)");
      Reflect.set(info, "fontSize", "96");
      Reflect.set(info, "textFontSize", "48");
      Reflect.set(info, "content", "与第三方系统数据交互中，请耐心等待...");
      Reflect.set(this.roomInfo, "visible", true);
      Reflect.set(this.roomInfo, "info", info);
    },

    handleSurgeryInfo() {
      let info = Object();
      Reflect.set(info, "data", {
        treatingMsg: "请xx患者家属<br/>到手术处等待",
      });
      Reflect.set(this.surgeryInfo, "visible", true);
      Reflect.set(this.surgeryInfo, "info", info);
    },

    // 报到选择业务
    handleReportBusinessShow() {
      let info = Object();
      let reportPickInfo = this.$store.getters["getReportPickInfo"];
      Reflect.set(info, "options", reportPickInfo["mockData"]);
      Reflect.set(info, "time", 60);
      Reflect.set(info, "content", "请选择你要报到的业务");
      Reflect.set(info, "fontSize", 60);
      Reflect.set(info, "color", "#333333");
      Reflect.set(info, "fontWeight", 500);
      Reflect.set(this.reportInfo, "visible", true);
      Reflect.set(this.reportInfo, "info", info);
    },

    // 报到科室
    handleReportDeptShow() {
      let info = Object();
      let reportDeptInfo = this.$store.getters["getReportDeptInfo"];

      let obj = [
        {
          registerId: "1235649846165165",
          registerObjId: "3235649846165165",
          registerObjName: "门诊通号",
          patientName: "韩斌",
        },
        {
          registerId: "3235649846165165",
          registerObjId: "5235649846165165",
          registerObjName: "门诊通号2",
        },
      ];

      Reflect.set(info, "reportDeptInfo", reportDeptInfo);
      Reflect.set(info, "signList", obj);
      Reflect.set(info, "deptList", reportDeptInfo);
      Reflect.set(info, "time", 99);
      Reflect.set(this.reportDeptInfo, "visible", true);
      Reflect.set(this.reportDeptInfo, "info", info);
    },

    // 报道机选择医生
    handleReportDRShow() {
      let info = Object();
      let reportDoctorInfo = this.$store.getters["getReportDoctorInfo2"];
      let patientInfo = {
        registerId: "1235649846165165",
        registerObjId: "3235649846165165",
        registerObjName: "门诊通号",
        patientName: "韩斌",
      };
      Reflect.set(info, "time", 99);
      Reflect.set(info, "DRList", reportDoctorInfo);
      Reflect.set(info, "patientInfo", patientInfo);
      Reflect.set(this.reportDRInfo, "visible", true);
      Reflect.set(this.reportDRInfo, "info", info);
    },

    // 门诊弹窗
    handleWaitingShow() {
      let info={
        "deptName": "门诊药房",
        "treatmentRoomName": "耳鼻喉诊室",
        "workStationName": "",
        "registerObjName": "西药",
        "treatingAlert": true,
        "waitingAlert": false,
        "currPatient": [
          {
            "bookId": null,
            "queuingId": "1906882664551207000",
            "deptName": "门诊药房",
            "orderNo": "2",
            "orderPrefix": null,
            "orderNumber": null,
            "orderTag": null,
            "orderTagColor": null,
            "colorPrefix": null,
            "ftColor": null,
            "bgColor": null,
            "patientName": "西***2",
            "patientCardNo": null,
            "patientIdNo": "10012",
            "patientShowNo": null,
            "treatType": "0",
            "treatStatus": null,
            "registerObjName": "西药",
            "registerObjId": null,
            "registerObjSimpleName": "西药",
            "registerObjGroupName": null,
            "registerObjGroupSimpleName": null,
            "workerStationId": null,
            "treatmentRoomName": null,
            "treatmentRoomShortName": null,
            "deptCode": null,
            "doctorCode": null,
            "doctorName": null
          }
        ],
        "waitPatient": [
          {
            "bookId": null,
            "queuingId": "1906882664551207000",
            "deptName": "门诊药房",
            "orderNo": "2",
            "orderPrefix": null,
            "orderNumber": null,
            "orderTag": null,
            "orderTagColor": null,
            "colorPrefix": null,
            "ftColor": null,
            "bgColor": null,
            "patientName": "西***2",
            "patientCardNo": null,
            "patientIdNo": "10012",
            "patientShowNo": null,
            "treatType": "0",
            "treatStatus": null,
            "registerObjName": "西药",
            "registerObjId": null,
            "registerObjSimpleName": "西药",
            "registerObjGroupName": null,
            "registerObjGroupSimpleName": null,
            "workerStationId": null,
            "treatmentRoomName": null,
            "treatmentRoomShortName": null,
            "deptCode": null,
            "doctorCode": null,
            "doctorName": null
          }
        ],
        "treatingVoiceContentConfig": [
          {
            "name": "请",
            "type": "text"
          },
          {
            "type": "patientInfo",
            "name": "2西***2",
          },
          {
            "name": "到",
            "type": "text"
          },
          {
            "name": "窗口01",
            "type": "treatmentRoomName"
          },
          {
            "name": "门口等候",
            "type": "text"
          }
        ],
        "waitingVoiceContent": "",
        "checkList": [
          1,
          3
        ],
        "registerObjNameKey": "registerObjName",
        "current": {
          "content": "就诊"
        },
        "waiting": {
          "content": "候诊"
        },
        "popupBackground": "",
        "overlayBackground": "",
        "data": {
          "msgId": "63e595b341d74d60ba4add33c2f1ac40",
          "msgCode": "Qcss_Call_Up_Msg",
          "msgContent": {
            "workerId": 22545,
            "workerName": "lhd",
            "terminalName": "",
            "deptName": "门诊药房",
            "workStationId": 452,
            "treatmentRoomName": "窗口01",
            "treatingPatient": {
              "bookId": null,
              "queuingId": "1906882664551207000",
              "deptName": "门诊药房",
              "orderNo": "2",
              "orderPrefix": null,
              "orderNumber": null,
              "orderTag": null,
              "orderTagColor": null,
              "colorPrefix": null,
              "ftColor": null,
              "bgColor": null,
              "patientName": "西***2",
              "patientCardNo": null,
              "patientIdNo": "10012",
              "patientShowNo": null,
              "treatType": "0",
              "treatStatus": null,
              "registerObjName": "西药",
              "registerObjId": null,
              "registerObjSimpleName": "西药",
              "registerObjGroupName": null,
              "registerObjGroupSimpleName": null,
              "workerStationId": null,
              "treatmentRoomName": null,
              "treatmentRoomShortName": null,
              "deptCode": null,
              "doctorCode": null,
              "doctorName": null
            },
            "treatingPatientList": [
              {
                "bookId": null,
                "queuingId": "1906882664551207000",
                "deptName": "门诊药房",
                "orderNo": "2",
                "orderPrefix": null,
                "orderNumber": null,
                "orderTag": null,
                "orderTagColor": null,
                "colorPrefix": null,
                "ftColor": null,
                "bgColor": null,
                "patientName": "西***2",
                "patientCardNo": null,
                "patientIdNo": "10012",
                "patientShowNo": null,
                "treatType": "0",
                "treatStatus": null,
                "registerObjName": "西药",
                "registerObjId": null,
                "registerObjSimpleName": "西药",
                "registerObjGroupName": null,
                "registerObjGroupSimpleName": null,
                "workerStationId": null,
                "treatmentRoomName": null,
                "treatmentRoomShortName": null,
                "deptCode": null,
                "doctorCode": null,
                "doctorName": null
              }
            ],
            "waitingPatientList": [],
            "voicePrompt": "2",
            "treatingAlert": true,
            "treatingVoice": true,
            "treatingVoiceCount": 1,
            "waitingVoicePlayUrl": null,
            "waitingAlert": false,
            "waitingVoice": false,
            "waitingVoiceCount": 0,
            "treatingVoiceContentConfig": [
              {
                name: "请",
                type: "text",
              },
              // {
              //   name: "患者号",
              //   type: "orderNo",
              // },
              // {
              //   name: "患者姓名",
              //   type: "patientName",
              // },
              {
                name: "到",
                type: "text",
              },
              {
                name: "诊室",
                type: "treatmentRoomName",
              },
              {
                name: "门口等候",
                type: "text",
              },
            ],
            "waitingVoiceContent": ""
          }
        },
        "currPatientInfo": [
          {
            "name": "请",
            "type": "text"
          },
          {
            "type": "patientInfo",
            "name": "2西***2",
            "tempName": [
              "2西***2"
            ]
          },
          {
            "name": "到",
            "type": "text"
          },
          {
            "name": "窗口01",
            "type": "treatmentRoomName"
          },
          {
            "name": "就诊",
            "type": "text"
          }
        ]
      };
      Reflect.set(this.callPatientCurrentInfo, "visible", true);
      Reflect.set(this.callPatientCurrentInfo, "info", info);
    },

    // 候诊屏药房窗口
    handleWaitingWindow() {
      let info={
        "deptName": "门诊药房",
        "treatmentRoomName": "窗口01",
        "workStationName": "",
        "registerObjName": "西药",
        "treatingAlert": true,
        "waitingAlert": false,
        "currPatient": [
          {
            "bookId": null,
            "queuingId": "1906882664551207000",
            "deptName": "门诊药房",
            "orderNo": "2",
            "orderPrefix": null,
            "orderNumber": null,
            "orderTag": null,
            "orderTagColor": null,
            "colorPrefix": null,
            "ftColor": null,
            "bgColor": null,
            "patientName": "西***2",
            "patientCardNo": null,
            "patientIdNo": "10012",
            "patientShowNo": null,
            "treatType": "0",
            "treatStatus": null,
            "registerObjName": "西药",
            "registerObjId": null,
            "registerObjSimpleName": "西药",
            "registerObjGroupName": null,
            "registerObjGroupSimpleName": null,
            "workerStationId": null,
            "treatmentRoomName": null,
            "treatmentRoomShortName": null,
            "deptCode": null,
            "doctorCode": null,
            "doctorName": null
          }
        ],
        "waitPatient": [],
        "treatingVoiceContentConfig": [
          {
            "name": "请",
            "type": "text"
          },
          {
            "type": "patientInfo",
            "name": "2西***2",
            "tempName": [
              "2西***2"
            ]
          },
          {
            "name": "到",
            "type": "text"
          },
          {
            "name": "窗口01",
            "type": "treatmentRoomName"
          },
          {
            "name": "就诊",
            "type": "text"
          }
        ],
        "waitingVoiceContent": "",
        "checkList": [
          1,
          3
        ],
        "registerObjNameKey": "registerObjName",
        "current": {
          "content": "就诊"
        },
        "waiting": {
          "content": "候诊"
        },
        "popupBackground": "",
        "overlayBackground": "",
        "data": {
          "msgId": "63e595b341d74d60ba4add33c2f1ac40",
          "msgCode": "Qcss_Call_Up_Msg",
          "msgContent": {
            "workerId": 22545,
            "workerName": "lhd",
            "terminalName": "",
            "deptName": "门诊药房",
            "workStationId": 452,
            "treatmentRoomName": "窗口01",
            "treatingPatient": {
              "bookId": null,
              "queuingId": "1906882664551207000",
              "deptName": "门诊药房",
              "orderNo": "2",
              "orderPrefix": null,
              "orderNumber": null,
              "orderTag": null,
              "orderTagColor": null,
              "colorPrefix": null,
              "ftColor": null,
              "bgColor": null,
              "patientName": "西***2",
              "patientCardNo": null,
              "patientIdNo": "10012",
              "patientShowNo": null,
              "treatType": "0",
              "treatStatus": null,
              "registerObjName": "西药",
              "registerObjId": null,
              "registerObjSimpleName": "西药",
              "registerObjGroupName": null,
              "registerObjGroupSimpleName": null,
              "workerStationId": null,
              "treatmentRoomName": null,
              "treatmentRoomShortName": null,
              "deptCode": null,
              "doctorCode": null,
              "doctorName": null
            },
            "treatingPatientList": [
              {
                "bookId": null,
                "queuingId": "1906882664551207000",
                "deptName": "门诊药房",
                "orderNo": "2",
                "orderPrefix": null,
                "orderNumber": null,
                "orderTag": null,
                "orderTagColor": null,
                "colorPrefix": null,
                "ftColor": null,
                "bgColor": null,
                "patientName": "西***2",
                "patientCardNo": null,
                "patientIdNo": "10012",
                "patientShowNo": null,
                "treatType": "0",
                "treatStatus": null,
                "registerObjName": "西药",
                "registerObjId": null,
                "registerObjSimpleName": "西药",
                "registerObjGroupName": null,
                "registerObjGroupSimpleName": null,
                "workerStationId": null,
                "treatmentRoomName": null,
                "treatmentRoomShortName": null,
                "deptCode": null,
                "doctorCode": null,
                "doctorName": null
              }
            ],
            "waitingPatientList": [],
            "voicePrompt": "2",
            "treatingVoicePlayUrl": "http://192.168.31.42:7000/tmp/voice/20250401/calling/5eca20d69d084cceb47517478a6c0ecb.wav",
            "treatingAlert": true,
            "treatingVoice": true,
            "treatingVoiceCount": 1,
            "waitingVoicePlayUrl": null,
            "waitingAlert": false,
            "waitingVoice": false,
            "waitingVoiceCount": 0,
            "treatingVoiceContentConfig": [
              {
                name: "请",
                type: "text",
              },
              // {
              //   name: "患者号",
              //   type: "orderNo",
              // },
              // {
              //   name: "患者姓名",
              //   type: "patientName",
              // },
              {
                name: "到",
                type: "text",
              },
              {
                name: "诊室",
                type: "treatmentRoomName",
              },
              {
                name: "取药",
                type: "text",
              },
            ],
            "waitingVoiceContent": ""
          }
        },
        "treatingVoicePlayUrl": "http://192.168.31.42:7000/tmp/voice/20250401/calling/5eca20d69d084cceb47517478a6c0ecb.wav",
        "currPatientInfo": [
          {
            "name": "请",
            "type": "text"
          },
          {
            "type": "patientInfo",
            "name": "2西***2",
            "tempName": [
              "2西***2"
            ]
          },
          {
            "name": "到",
            "type": "text"
          },
          {
            "name": "窗口01",
            "type": "treatmentRoomName"
          },
          {
            "name": "就诊",
            "type": "text"
          }
        ]
      };
      Reflect.set(this.callPatientWindowInfo, "visible", true);
      Reflect.set(this.callPatientWindowInfo, "info", info);
    },

    handleBusiness(row) {
      this.handleCancel();
    },

    handleSureDoctor(row) {
      console.log(row);
    },

    // 检索提交
    handleSubmit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          const paramsInfo =
            this.$store.getters["template/getTemplateListParamsInfo"];
          let params = this.$lodash.merge(paramsInfo, this.form);
          this.$store.dispatch("template/setTemplateListParams", params);
          this.templateListInfo();
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },

    handleResets(formName) {
      this.$nextTick(() => {
        let paramsInfo = {
          pageNum: 1,
          pageSize: 10,
          title: "",
          devType: "",
          bizType: "",
        };
        this.$store.dispatch("template/setTemplateListParams", paramsInfo);
        this.$refs[formName].resetFields();
        this.templateListInfo();
      });
    },
  },

  destroyed() {
    let params = Object();
    Reflect.set(params, "pageNum", 1);
    Reflect.set(params, "pageSize", 10);
    this.$store.dispatch("template/setTemplateListParams", params);
  },
};
</script>

<style lang="scss" scoped>
@import "./assets/style";
</style>
